package javaweb.dao.impl;

import javaweb.dao.UserDao;
import javaweb.pojo.User;

/**
 * @author shkstart
 * @creat -07-14 15:07
 */
public class UserDaoImpl extends BaseDao implements UserDao {
    public UserDaoImpl(){

    }
    @Override
    public User queryUsername(String username) {
       String sql="select * from t_user where username=?";
        User user = quryForOne(User.class, sql, username);
       // String name = user.getName();
        return user;
    }

    @Override
    public int svaeUser(User user) {
        String sql="insert into t_user(`username`,`password`,`email`)VALUES(?,?,?)";
        return upDate(sql,user.getUsername(),user.getPassword(),user.getEmail());
    }

    @Override
    public User queryUsernameAndPassword(String username, String password) {
        String sql="select `id`,`username`,`password` from t_user where username=? and password=?";
        return quryForOne(User.class,sql,username,password);
    }
}
